<?php
	class SuKien
	{
		public $sk_ma;
		public $sk_ten;
		public $sk_ngay_bat_dau;
		public $sk_ngay_ket_thuc;
		public $sk_mo_ta;
		public $sk_ma_gian_hang;
		public $sk_tinh_trang;
		
		public static function DangSuKien($SuKien)
		{
			$querySQL = "insert into Su_Kien (sk_ten, sk_ngay_bat_dau, sk_ngay_ket_thuc, sk_mo_ta, sk_ma_gian_hang, sk_tinh_trang) values(
					'$SuKien->sk_ten',
					'$SuKien->sk_ngay_bat_dau',
					'$SuKien->sk_ngay_ket_thuc',
					'$SuKien->sk_mo_ta',
					'$SuKien->sk_ma_gian_hang',
					'1')";
			return InsertAndGetID($querySQL);
			StopConnection();				
		}
		
		public static function CapNhatSuKien($SuKien)
		{
			$querySQL = "update Su_Kien set 		
						sk_ngay_bat_dau = '$SuKien->sk_ngay_bat_dau',
						sk_ngay_ket_thuc = '$SuKien->sk_ngay_ket_thuc',
						sk_ten = '$SuKien->sk_ten',
						sk_mo_ta = '$SuKien->sk_mo_ta'
						WHERE sk_ma = '$SuKien->sk_ma'";
			QuerySQL($querySQL);
			StopConnection();				
		}
		
		public static function XoaSuKienSuKien($IdSuKien)
		{
			$querySQL = "update Su_Kien set
						sk_tinh_trang = '0'
						WHERE sk_ma = '$IdSuKien'";
			QuerySQL($querySQL);
			StopConnection();				
		}
		
		public static function ChiTietSuKien($Ma)
		{
			$querySQL = "
					select *
					from Su_Kien
					where sk_tinh_trang = 1 and sk_ma = $Ma";
			$results = QuerySQL($querySQL);
			while($row = mysql_fetch_array($results))
			{
				$SuKien = new SuKien;
				$SuKien->sk_ma = $row["sk_ma"];
				$SuKien->sk_ten = $row["sk_ten"];
				$SuKien->sk_ngay_bat_dau = $row["sk_ngay_bat_dau"];
				$SuKien->sk_ngay_ket_thuc = $row["sk_ngay_ket_thuc"];
				$SuKien->sk_mo_ta = $row["sk_mo_ta"];
				$SuKien->sk_tinh_trang = $row["sk_tinh_trang"];
				$SuKien->sk_ma_gian_hang = $row["sk_ma_gian_hang"];
				StopConnection();
				return $SuKien;	
			}
		}
	}
?>